package com.ecable.action;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Vector;
import com.ecable.exception.ConnectionException;
import com.ecable.exception.DataNotFoundException;
import com.ecable.bean.ProfileTO;
import com.ecable.daoImpl.ProfileDAO;

import com.ecable.util.UtilConstants;

public class UpdateOperatorsInfoAction extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String path = "";

		Vector<ProfileTO> opf = null;

		try {


				int userid = Integer.parseInt(request.getParameter("userid"));

				opf = new ProfileDAO().getViewProfile(userid);
			

			if (opf != null) {

				request.setAttribute("status", UtilConstants._UPDATE_OPERATOR);

				request.setAttribute("updateoperator", opf);

				path = UtilConstants._UPDATE_OPERATORS_HOME;

			} else {

				request.setAttribute("status",
						UtilConstants._ALL_OPERATOR_FAILED);

				path = UtilConstants._UPDATE_OPERATORS_HOME;

			}

		} catch (Exception e) {
			e.printStackTrace();

			request.setAttribute("status", UtilConstants._INVALIED_ENTRY);

			path = UtilConstants._UPDATE_OPERATORS_HOME;

		}

		RequestDispatcher rd = request.getRequestDispatcher(path);

		rd.forward(request, response);

	}

}
